package com.semidata.rtd.core.log;

import java.io.PrintWriter;
import java.io.StringWriter;

import com.semidata.rtd.core.service.ServiceManager;

public class Logger {
    
    public static void log(String name, String content) {
        if (name == null || content == null)
            return;
        ServiceManager.send(LogService.class, new LogEvent(name, content));
    }
    
    public static void log(String name, Throwable e) {
        if (name == null || e == null)
            return;
        StringWriter content = new StringWriter();
        PrintWriter writer = new PrintWriter(content);
        e.printStackTrace(writer);
        ServiceManager.send(LogService.class, new LogEvent(name, content.toString()));
    }
}
